function toggle_div(id) {
  el = document.getElementById(id);
  on = (el.className == "Visible");
  new_class = on ? "Hidden" : "Visible";
  el.className = new_class;
}

function set_div_class(id, new_class) {
  el = document.getElementById(id);
  el.className = new_class;
}


function select_tab(id) {
  var pane = document.getElementById(id);
  var group = pane.parentNode;

  for(var i in group.childNodes) {
    var node = group.childNodes[i];
    if (node.className && node.className.match('TabPane')) {
      var link = document.getElementById(node.id+"Tab");
      if (node.id == id) {
        node.className = "TabPane Selected";
        link.className = "Selected";
      } else {
        node.className = "TabPane";
        link.className = null;
      }
    }
  }
}

function deselect_tab(id) {
  var pane = document.getElementById(id);
  var tab = document.getElementById(id+"Tab");

  pane.className = "TabPane";
  tab.className = null;
}

function tab_click(id) {
  var pane = document.getElementById(id);
  if (pane.className.match('Selected')) {
    deselect_tab(id);
  } else {
    select_tab(id);
  }
}
